import React from 'react'
import {Card} from 'antd'
import echartTheme from './../echartTheme'
import echarts from 'echarts/lib/echarts'
//导入柱形图
import 'echarts/lib/chart/bar'
import 'echarts/lib/component/tooltip'
import 'echarts/lib/component/title'
import 'echarts/lib/component/legend'
import 'echarts/lib/component/markPoint'
import ReactCharts from 'echarts-for-react'
export default class Bar extends React.Component{
    componentWillMount(){
        echarts.registerTheme('tomarow',echartTheme)
    }
    getOption =()=>{
      let  option = {
           title:{
               text:"用户骑行订单"
           },
            tooltip : {
                trigger: 'axis',
                axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                    type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis : [
                {
                    type : 'category',
                    data : ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期天'],
                    axisTick: {
                        alignWithLabel: true
                    }
                }
            ],
            yAxis : [
                {
                    type : 'value'
                }
            ],
            series : [
                {
                    name:'骑行人数',
                    type:'bar',
                    data:[1000, 5200, 2000, 3340, 3900, 3300, 2200]
                }
            ]
        };
      return option
    }
    getOption2 =()=>{
        let  option = {
            title:{
                text:"用户骑行订单"
            },
            legend:{
               data:["ofo","摩拜","缆车"]
            },
            tooltip : {
                trigger: 'axis',
                axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                    type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis : [
                {
                    type : 'category',
                    data : ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期天'],
                    axisTick: {
                        alignWithLabel: true
                    }
                }
            ],
            yAxis : [
                {
                    type : 'value'
                }
            ],
            series : [
                {
                    name:'ofo',
                    type:'bar',
                    data:[41000, 5200,52000, 13340, 23900, 23300, 32200]
                },
                {
                    name:'摩拜',
                    type:'bar',
                    data:[3000, 4200, 1000, 22340, 13900, 53300, 12200]
                },
                {
                    name:'缆车',
                    type:'bar',
                    data:[2000, 5300, 4000, 3000, 1900, 3200, 1200]
                }
            ]
        };
        return option
    }
    render(){
        return(
            <div>
                <Card title="柱形图表之一">
                    <ReactCharts option={this.getOption()} theme="tomarow" style={{height:500}}/>
                </Card>
                <Card title="柱形图表之二" style={{marginTop:"10px"}}>
                    <ReactCharts option={this.getOption2()} theme="tomarow" style={{height:500}}/>
                </Card>
            </div>
        )
    }
}